package com.hzw.preview.day01;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Demo02 {

    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
        Class<?> aClass = Class.forName("com.GlacierDimension.hzw.User");
        Method setName = aClass.getMethod("setName", String.class);
        Method setAge = aClass.getMethod("setAge", int.class);

        Object o = aClass.newInstance();
        setName.invoke(o,"zhen01");
        setAge.invoke(o,18);

        System.out.println(o);
    }
}
